package com.ylfstu.string_;

/**
 * @author:Joy_Yang
 * @date:2022/9/28
 * @version:1.0
 */
public class StringBufferExercise01 {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("hello").append("java");
        stringBuffer.insert(5,"my");
        System.out.println(stringBuffer);

        String s1 = "987623456.789";
        StringBuffer stringBuffer1 = new StringBuffer(s1);
//        stringBuffer1.insert(stringBuffer1.indexOf(".") - 3, ",");
        for (int i = stringBuffer1.indexOf(".") - 3; i > 0 ; i -= 3) {
            stringBuffer1 = stringBuffer1.insert(i, ",");
        }

        System.out.println(stringBuffer1);
    }
}
